
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main()
    {
        int pfds[2];
        char *arg[] = {"head","-c", "50", "/proc/cpuinfo", NULL};//arg for execve head
        char *arg2[] = {"wc", NULL};//arg for wc

        if( pipe(pfds)==0 )
            {
                if( fork()==0 )
                    {
                        close(1);
                        dup2(pfds[1],1);
                        close(pfds[0]);                       
                        execvp("head",arg);
                        
                    }
                else
                    {
                        close(0);
                        dup2(pfds[0],0);
                        close(pfds[1]);
                        execvp("wc",arg2);

                        
                    }
            }
        return 0;
        
    }

